;;;
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;	http://www.paracadd.com
;;;	All rights reserved.
;;;
;;;       Copyright:      4-22-97
;;;       Edited:         4-22-97
;;;
(defun c:ublka ()
  (setq iniblk (entsel "\nSelect block to update. "))
  (setq inient (entget (car iniblk)))
  (if (and iniblk (eq(cdr(assoc 0 inient))"INSERT"))
    (if (eq(cdr(assoc 66 inient))1)
      (progn
        (setq attlst nil)
        (setq nxtent (entget(entnext(car iniblk))))
        (while (/=(cdr(assoc 0 nxtent))"SEQEND")
          (if (eq(cdr(assoc 0 nxtent))"ATTRIB")
            (if attlst
              (setq attlst
                (append attlst
                        (list(assoc 2 nxtent)(assoc 1 nxtent))
                )
              )
              (setq attlst (list(assoc 2 nxtent)(assoc 1 nxtent)))
            )
          )
          (setq nxtent (entget(entnext(cdar nxtent))))
        )
        (setq cblknm (cdr(assoc 2 inient)))
        (setq blknam (ustr 1 (strcat "Block name to update " cblknm " with ") cblknm nil))
        (setq updblk (findfile (strcat blknam ".DWG")))
        (if updblk
          (if (eq(ukword 1 "Yes No" (strcat "Redefine block using " updblk "?") "Yes")"Yes")
            (progn
              (setq att_rq (getvar"attreq"))
              (setvar "attreq" 0)
              (entdel (car iniblk))
              (command "_.insert" (strcat blknam "=")
                       (cdr(assoc 10 inient))
                       (cdr(assoc 41 inient))
                       (cdr(assoc 42 inient))
                       (cdr(assoc 50 inient))
              )
              (setq newent (entlast)
                    nxtent (entget(entnext newent)))
              (while (/=(cdr(assoc 0 nxtent))"SEQEND")
                (if (member (assoc 2 nxtent) attlst)
                  (progn
                    (setq attent
                      (subst (cadr(member (assoc 2 nxtent) attlst))
                             (assoc 2 nxtent)
                             nxtent
                      )
                    )
                    (entmod attent)
                  )
                )
                (setq nxtent (entget(entnext(cdar nxtent))))
              )
              (entupd newent)
              (setvar "attreq" att_rq)
            )
            (princ "\nFunction cancelled. ")
          )
          (princ (strcat "\nFile \"" blknam ".DWG\" not found. *Cancel* "))
        )
      )
      (princ "\nBlock has no attributes. ")
    )
    (princ "\nNo block selected. ")
  )
)